package com.huang.core.widget.recyclerview.decoration

import android.graphics.Color
import android.view.View
import com.huang.core.widget.recyclerview.decoration.base.Y_Divider
import com.huang.core.widget.recyclerview.decoration.base.Y_DividerBuilder
import com.huang.core.widget.recyclerview.decoration.base.Y_ItemDecoration

class LinearMarginDecoration(
        private var orientation: Int,
        private val specDb: Float = 0f
) : Y_ItemDecoration() {

    override fun getDivider(itemPosition: Int, itemCount: Int, view: View): Y_Divider {
        if (orientation == VERTICAL) {
            if (itemPosition == 0) {
                return Y_DividerBuilder()
                        .setTopSideLine(false, Color.TRANSPARENT, specDb, 0f, 0f)
                        .create()
            } else return Y_DividerBuilder()
                    .setTopSideLine(true, Color.TRANSPARENT, specDb, 0f, 0f)
                    .create()
        } else {
            if (itemPosition == 0) {
                return Y_DividerBuilder()
                        .setLeftSideLine(false, Color.TRANSPARENT, specDb, 0f, 0f)
                        .create()
            } else return Y_DividerBuilder()
                    .setLeftSideLine(true, Color.TRANSPARENT, specDb, 0f, 0f)
                    .create()
        }

    }


    companion object {
        val HORIZONTAL = 0
        val VERTICAL = 1
    }

}